import java.util.ArrayList;
import java.util.Iterator;


public class Flock implements Quackable {
	ArrayList quackers = new ArrayList();
	
	public void add(Quackable quacker) {
		quackers.add(quacker);
	}
	
	@Override
	public void quack() {
		Iterator i = quackers.iterator();
		while(i.hasNext()) {
			Quackable quacker = (Quackable)i.next();
			quacker.quack();
		}

	}

	@Override
	public void registerObserver(Observer observer) {
		Iterator i = quackers.iterator();
		while(i.hasNext()) {
			Quackable quacker = (Quackable)i.next();
			quacker.registerObserver(observer);
		}

	}
	
	@Override
	public void notifyObservers() {
		Iterator i = quackers.iterator();
		while(i.hasNext()) {
			Quackable quacker = (Quackable)i.next();
			quacker.notifyObservers();
		}

	}
}
